<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateShortUrlMappingsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('short_url_mappings', function (Blueprint $table) {
            $table->id();
            $table->char('code', 5)->unique('code')->comment('短Code');
            $table->string('url', 255)->default('')->comment('url');
            $table->unsignedInteger('number')->default(0)->comment('访问次数');
            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->comment = '短链映射表';

            // 让唯一索引可以区分大小写
            $table->collation = 'utf8mb4_0900_as_cs';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('short_url_mappings');
    }
}
